package inet.app.controller.parser;


import inet.app.controller.connect.JsonParser;
import inet.app.model.object.Lbt_Item;

import java.util.ArrayList;

import org.json.JSONObject;

import android.util.Log;

public class Parser_Lbt {


	private ArrayList<Lbt_Item> list = new ArrayList<Lbt_Item>();
	private Lbt_Item item;
	private String ITEMS = "items";
	private String CODE = "code";
	private String NAME = "name";
	private String DATE = "date";
	private String MOST = "most";
	private String LEAST= "least";
	private String CURR = "curr";
	
	public Parser_Lbt () {
		
	}
	public ArrayList<Lbt_Item> getList(String url) {
		list = new ArrayList<Lbt_Item>();
		JSONObject jobject,object,job_items;
		JsonParser jParser = new JsonParser();
		jobject = jParser.getJSONFromUrl(url);
		try {
				String items = jobject.getString(ITEMS);
				job_items = new JSONObject(items);
				String code= job_items.getString(CODE);
				String name= job_items.getString(NAME);
				String date= job_items.getString(DATE);
				String most= job_items.getString(MOST);
				String least= job_items.getString(LEAST);
				String luachon= job_items.getString(CURR);
				
				item = new Lbt_Item(code, name, date, most, least, luachon);
				list.add(item);
				
			return list;
        } catch (Exception e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
            return null;
        }
		
	}


}
